var gulp = require('gulp'),
    browsersync = require('browser-sync'),
    autoprefixer = require('gulp-autoprefixer');
watch = require("gulp-watch");

gulp.task('testAutoFx', function(done) {
    gulp.src('./lib/theme/style.css')
        .pipe(autoprefixer({
            browsers: ['last 2 versions', 'Android >= 4.0'],
            cascade: true, //是否美化属性值 默认：true 像这样：
            remove: true //是否去掉不必要的前缀 默认：true 
        }))
        .pipe(gulp.dest('./lib/theme/css/'))
    done()
});

gulp.task('auto', function() {
    watch('./public/src/styleTheme/style.css', gulp.series('testAutoFx'));
    var files = [
        './public/*.html',
        './public/*/*.html',
        './*.html',
        './lib/image/*.jpg',
        './lib/image/*.png',
        './lib/theme/*.less',
        './lib/theme/*.css',
        './lib/*/*.js',
        './lib/pageJavascript/*/*.js'
    ];
    browsersync.init(files, {
        server: {
            baseDir: './'
        }
    })
});

gulp.task('default', gulp.series('auto'));